home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: uu4news.netcom.com!zodiac!szh
- From: szh@zcon.com (Syed Zaeem Hosain)
- Subject: Re: Clearing the keyboard
- Message-ID: <1996Jan26.232559.11147@zcon.com>
- Sender: szh@zcon.com (Syed Zaeem Hosain)
- Nntp-Posting-Host: zodiac
- Reply-To: szh@zcon.com
- Organization: Z Consulting Group
- References: <4e7amq$nhd@mercury.IntNet.net>
- Date: Fri, 26 Jan 1996 23:25:59 GMT
-
- In article <4e7amq$nhd@mercury.IntNet.net>, jtomich@IntNet.net (Jeff Tomich) writes:
- >: > Huh? Once the buffer is caught up, it shouldn't continue, but you
- >: > might want to try fflush(stdin); just the same. ...
- >
- >: Why? Are there any other pieces of undefined behavior that you think
- >: people "might want to try?" Nor does the C language defines what
- >: happens if you discharge a shotgun at your computer; maybe you "might
- >: want to try" that, also.
- >:
- >
- >Why not this;
- >
- >while(kbhit())
- > getch();
- >
- >this should clear the keyboard...
-
- Really? There ain't no such thing in my Sun system! Check out the
- following:
-
- zodiac{2057}szh: grep -i kbhit /usr/include/*.h
- zodiac{2058}szh: grep -i getch /usr/include/*.h
- /usr/include/curses.h:# define getch() VOID(wgetch(stdscr))
- /usr/include/curses.h:#define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
- /usr/include/curses.h:#define mvgetch(y,x) mvwgetch(stdscr,y,x)
- /usr/include/stdio.h:#define getchar() getc(stdin)
- zodiac{2059}szh: cat foo.c
- #include <curses.h>
- #include <stdio.h>
-
- int main ()
- {
- while (kbhit() )
- getch();
- return(0);
- }
- zodiac{2060}szh: gcc -o foo foo.c
- collect2: ld returned 2 exit status
- ld: Undefined symbol
- _stdscr
- _kbhit
- _wgetch
- zodiac{2061}szh: gcc -o foo foo.c -lcurses
- collect2: ld returned 2 exit status
- ld: Undefined symbol
- _kbhit
- zodiac{2062}szh:
-
- This just goes to show that if you are going to provide an answer to a
- question (that really should not be in this comp.lang.c newsgroup in
- the first place), that you should spend some effort to find a complete
- answer that is portable. Or certainly qualify your answer precisely!
- :-)
-
- There *is* a reason that the FAQ talks about this being one of those
- non-portable things. See section 19. "System Dependencies" in the FAQ
- for more info and please ask these questions (and answer them) in a
- newsgroup that is more specific to the system of choice.
-
- Z
-
-
-
- --
- -------------------------------------------------------------------------
- | Syed Zaeem Hosain P. O. Box 610097 (408) 441-7021 |
- | Z Consulting Group San Jose, CA 95161 szh@zcon.com |
- -------------------------------------------------------------------------
-